package cn.wanho.config;

import cn.wanho.interceptor.MyInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public MyInterceptor myInterceptor(){
        return new MyInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //所有的请求都进行处理，同时对于请求不处理login register
        registry.addInterceptor(myInterceptor()).addPathPatterns("/**").
                excludePathPatterns("/user/login","/user/register","/article/allarticle");
    }
    //处理文件异常
//    @Bean
//    public CommonsMultipartResolver getCommonsMultipartResolver() {
//        CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
//        commonsMultipartResolver.setMaxUploadSize(20971520);
//        commonsMultipartResolver.setMaxInMemorySize(1048576);
//        return commonsMultipartResolver;
//    }


}
